<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@page
	import="java.util.*,net.pws.common.security.*,net.pws.common.security.spi.*,net.pws.common.security.spi.resource.*"%>
<%@page import="org.apache.commons.tfs.VersionType"%>
<%@page import="net.pws.oos.web.dto.ResourceDto"%>
<%@page import="net.pws.common.util.DateUtils"%>
<%@page import="org.apache.commons.tfs.LicenceFactory"%>
<%@page import="org.apache.commons.tfs.Licence"%>
<% 
String _basePath = request.getContextPath();
String ctx = request.getContextPath();
String _serverName = request.getServerName();

int warnDays = 7;
Licence licence = LicenceFactory.getInstance().getLicence();
VersionType lsaType = licence.getVersionType();
int unvalidDays = DateUtils.diffDateOD(new Date(), licence.getExpiry());
String unit = new String(licence.getUnit().getBytes(), "utf-8");
String lsaName = new String(licence.getName().getBytes(), "utf-8");
%>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="Pragma" content="no-cache" />
<title><%=unit%> - <%=lsaName%></title>

<link href="<%=ctx%>/css/jquery.ui.1.8.16.custom.css" rel="stylesheet" type="text/css" />
<link href="<%=ctx%>/css/bootstrap.css" rel="stylesheet" type="text/css" />
<link href="<%=ctx%>/css/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
	var ctx = '<%=ctx%>';
</script>

<script type="text/javascript" src="<%=ctx%>/js/jquery-1.7.2.js"></script>
<script type="text/javascript" src="<%=ctx%>/js/jquery.json.js"></script>
<script type="text/javascript" src="<%=ctx%>/js/jquery.jslist.js"></script>
<script type="text/javascript" src="<%=ctx%>/js/jquery.validate.js"></script>
<script type="text/javascript" src="<%=ctx%>/js/jquery.ui.1.8.16.custom.min.js"></script>
<script type="text/javascript" src="<%=ctx%>/js/jquery-ui.datepicker-zh-CN.js"></script>
<script type="text/javascript" src="<%=ctx%>/js/jquery.bootstrap-tab.js"></script>
<script type="text/javascript" src="<%=ctx%>/js/jquery.bootstrap-tooltip.js"></script>
<script type="text/javascript" src="<%=ctx%>/js/jquery.blockUI.js"></script>
<script type="text/javascript" src="<%=ctx%>/js/jquery.jstree.js"></script>
<script type="text/javascript" src="<%=ctx%>/js/jquery.maxlength.js"></script>
<script type="text/javascript" src="<%=ctx%>/js/jquery.timers.js"></script>
<script type="text/javascript" src="<%=ctx%>/js/jquery.marquee.js"></script>
<script type="text/javascript" src="<%=ctx%>/js/textareaAutoHeight.js"></script>
<script type="text/javascript" src="<%=ctx%>/js/jquery.cms.js"></script>
<script type="text/javascript" src="<%=ctx%>/js/cms.common.js"></script>
</head>
<body>


<div id="cms_top">
<div id="cms_top_wrap">
<div id="cms_top_user">
<ul>
	<li><i class="icon-user"></i>
	<%=SecurityContext.getContext().getName() %></li>
	<li>|</li>
	<li><i class="icon-off"></i> <a href="<%=ctx%>/logout" title="退出系统">退出</a></li>
	<li>|</li>
	<li><i class="icon-lock"></i> <a href="<%=ctx%>/biz/system/password.jsp" title="修改本人的密码">修改密码</a></li>
	<li>|</li>
	<li><i class="icon-download-alt"></i> <a href="<%=ctx%>/android/download.do" title="Android客户端软件下载">终端下载</a></li>
	<li>|</li>
	<li><i class="icon-envelope"></i> <a href="<%=ctx%>/biz/message/list.do" title="我的消息">消息<span id="myNewMsgCount" class="badge badge-warning hide">0</span></a></li>
</ul>
</div>
<div id="cms_top_tools">
	<ul id="myNewMessages" class="marquee">
	</ul>
</div>
</div>
</div>

<div class="content_area">

<div>
<div id="cms_logo">
</div>
</div>

<div class="header">
	<%
	if(unvalidDays <= warnDays) {
	%>
	<div class="alert alert-error lcs">
  		<strong>警告：</strong> <%=lsaName%>的授权还有<%=unvalidDays%>天到期，请联系管理员尽快更新授权文件！
	</div>
	<%
	}
	if(!licence.isFormalType()) {
	%>
	<div class="alert alert-error lcs">
  		<strong>警告：</strong> 您正在使用<%=lsaName + lsaType.getLabel()%>，请联系管理员尽快升级到正式版！
	</div>
	<%
	}
	%>
</div>

<div id="main">

<div class="cms_menu">
	<div class="border bg">
<%
String userId = SecurityContext.getContext().getId();
ICachedResource cachedResource = CachedResourceManagerFactory.getInstance().getObject().getCachedResource(userId);
IResource[] resources = cachedResource.getResources(IResource.MENU,true);
List<ResourceDto> topMenus = ResourceDto.from(Arrays.asList(resources));
for(int i = 0; i < topMenus.size(); i++){
	ResourceDto topMenu = topMenus.get(i);
	IResource[] subResources = cachedResource.getResourceChildren(topMenu.getId(), IResource.MENU, true);
%>
		<h2><i class="icon-th-list"></i><a href="<%= ctx + topMenu.getUrl()%>"><%= topMenu.getName() %></a></h2>
<%	
	if(subResources != null && subResources.length > 0){
		List<ResourceDto> subMenus = ResourceDto.from(Arrays.asList(subResources));
%>
		<ul class="quicklink">
<%		
		for(int j = 0; j < subMenus.size(); j++){
			ResourceDto subMenu = subMenus.get(j);
%>
			<li><i class="icon-chevron-right"></i><a href="<%= ctx + subMenu.getUrl()%>"><%= subMenu.getName() %></a></li>
<%		
		}
%>
		</ul>
<%
	}
}
%>
	</div>
</div>

<div class="cms_left">